﻿package builder
{
    import factory.MazeFactory;

    public class StandardMazeBuilder extends MazeBuilder
    {
        private var m_standardMazeFactory:MazeFactory;
        private var m_maze:Maze;

        public function StandardMazeBuilder()
        {
            m_standardMazeFactory = new MazeFactory();
        }

        override public function buildMaze():void
        {   
            m_maze = m_standardMazeFactory.MakeMaze();
        }

        override public function buildRoom(roomNumber:uint):void
        {   
            var room:Room = m_standardMazeFactory.MakeRoom(roomNumber);
            room.setSide(GameConstants.NORTH, m_standardMazeFactory.MakeWall());
            room.setSide(GameConstants.SOUTH, m_standardMazeFactory.MakeWall());
            room.setSide(GameConstants.EAST, m_standardMazeFactory.MakeWall());
            room.setSide(GameConstants.WEST, m_standardMazeFactory.MakeWall());
            m_maze.addRoom(room);
        }

        override public function buildDoor(firstNumber:uint, secondNumber:uint, firstSide:String, secondSide:String):void
        {
            var door:WallWithDoor = m_standardMazeFactory.MakeDoor(firstNumber, secondNumber);

            var room1:Room = m_maze.getRoomByNumber(firstNumber);
            room1.setSide(firstSide, door);

            var room2:Room = m_maze.getRoomByNumber(secondNumber);
            room2.setSide(secondSide, door);            
        }

        override public function GetMaze():Maze
        {   
            return m_maze;
        }
    }
}
